package com.twu.biblioteca.model.users;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

/**
 * Created with IntelliJ IDEA.
 * User: cschlumb
 * Date: 09/08/2013
 * Time: 13:17
 * To change this template use File | Settings | File Templates.
 */
public class User {

    private final Username username;
    private final byte[] hashedPassword;
    private final byte[] salt;
    private final String name;
    private final String email;
    private final String phone;

    public User(Username username, String password, String name, String email, String phone) {
        this.username = username;
        this.name = name;
        this.email = email;
        this.phone = phone;

        salt = SecurityUtils.getRandomSalt();
        hashedPassword = SecurityUtils.hashPassword(password, salt);
    }

    public byte[] getHashedPassword() {
        return hashedPassword;
    }

    public byte[] getPasswordSalt() {
        return salt;
    }

    public String getName() {
        return name;
    }

    public Username getUsername() {
        return username;
    }

    public String getEmail() {
        return email;
    }

    public String getPhone() {
        return phone;
    }
}
